cmake_minimum_required(VERSION 3.1)
project(OpenGL)

#包含目录
include_directories(./external/)
include_directories(./external/glfw3/include/)
include_directories(./external/glad/include/)
include_directories(./swy/)

#查找库文件位置
if(APPLE)
    link_directories(./external/glfw3/prebuild/mac/)
endif(APPLE)
if (WIN32)
    link_directories(./external/glfw3/prebuild/win/)
endif(WIN32)

#添加源文件到变量上
# aux_source_directory(./ MAIN_S)
aux_source_directory(./swy/shader/ SWY_S)
aux_source_directory(./external/glad/src/ GLAD_S)
aux_source_directory(./external/stb/ STB_S)
aux_source_directory(./external/glm/ GLM_S)

#保存所有需要编译的源文件
# set(SOURCES ${MAIN_S} ${GLAD_S})
set(SOURCES ./src/camera/main-camera.cpp ${SWY_S} ${GLAD_S} ${STB_S} ${GLAD_S})

#生成可执行文件
add_executable(OpenGL ${SOURCES})

#连接库文件
if(APPLE)
    target_link_libraries(OpenGL libglfw3.a)
endif(APPLE)

if(WIN32)
    target_link_libraries(OpenGL glfw3.lib)
endif(WIN32)

if(APPLE)
    # find_library(MAC_CoreFoundation CoreFoundation)
    # if(NOT MAC_CoreFoundation)
    #     message(FATAL_ERROR "MAC_CoreFoundation not found")
    # endif()
    # target_link_libraries(OpenGL ${MAC_CoreFoundation})

    #连接Apple MacOS库文件    
    target_link_libraries(OpenGL "-framework CoreFoundation")
    target_link_libraries(OpenGL "-framework CoreGraphics")
    target_link_libraries(OpenGL "-framework IOKit")
    target_link_libraries(OpenGL "-framework AppKit")
    target_link_libraries(OpenGL "-framework OpenGL")
endif(APPLE)